import React from 'react'
import {Pagination} from "antd"
import {useStore} from "react-redux"
function My_pagination({table_data,setSlice_data}) {
    const store = useStore()
    const my_pageSize = store.getState().table_reducer.pageSize
    const cur = store.getState().table_reducer.cur

    return (
        <div>
            <Pagination 
                onShowSizeChange={(cur,size)=>{
                console.log(cur,size);
                store.dispatch({
                    type:"SET_PAGESIZE",
                    payload:{
                        cur,
                        size
                    }
                })
                }} 
                hideOnSinglePage={true}
                current={cur}
                showSizeChanger={true} 
                pageSizeOptions={[5,10,15,20]} 
                pageSize={my_pageSize} 
                total={table_data.length} 
                onChange={(page,pageSize)=>{
                    setSlice_data(page,pageSize)
                }}
            />
        </div>
    )
}

export default My_pagination
